<?php

namespace Sm\AssBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Datetime;
use Sm\AssBundle\Entity\Style as Style;

/**
 * Srt
 *
 * @ORM\Table("sm_srt")
 * @ORM\Entity(repositoryClass="Sm\AssBundle\Entity\SrtRepository")
 */
class Srt
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
    
     /**
     * 
     * @ORM\ManyToOne(targetEntity="Sm\AssBundle\Entity\Ass", inversedBy="srts")
     * @ORM\JoinColumn(nullable=false) 
     */
    private $ass;
    
     /**
     * @var integer
     *
     * @ORM\Column(name="line", type="integer")
     */
    private $line;
    
    /**
     * @var string
     *
     * @ORM\Column(name="type", type="string", length=255)
     */
    private $type;
    
    /**
     * @var string
     *
     * @ORM\Column(name="start", type="string", length=255)
     */
    private $start;

    /**
     * @var string
     *
     * @ORM\Column(name="end", type="string", length=255)
     */
    private $end;

    /**
     * @var string
     *
     * @ORM\Column(name="content", type="text")
     */
    private $content;
    
    /**
     * @var datetime
     *
     * @ORM\Column(name="last_modified", type="datetime")
     */
    private $last_modified;
    
    /**
     * @var boolean
     *
     * @ORM\Column(name="is_modified", type="boolean")
     */
    private $is_modified;
    
    /**
    * @ORM\ManyToOne(targetEntity="Sm\AssBundle\Entity\Style", inversedBy="srts")
    * @ORM\JoinColumn(nullable=false) 
    */
    private $style;
    
    /*
     * Constructeur
     */
    public function __construct($options) {
        
        $this->ass              = isset($options['ass']) ? $options['ass'] : null;
        
        $defaults = $this->getDefaultOptions();
        
        $this->line             = $options['line'];
        $this->type             = isset($options['type']) ? $options['type'] : $defaults['type'];
        $this->start            = isset($options['start']) ? $options['start'] : $defaults['start'];
        $this->end              = isset($options['end']) ? $options['end'] : $defaults['end'];
        $this->content          = isset($options['content'])? $options['content'] : $defaults['content'];
        $this->last_modified    = new Datetime();
        $this->is_modified      = $options['is_modified'] ? $options['is_modified'] : $defaults['is_modified'];
        $this->style            = $options['style'] ? $options['style'] : $defaults['style'];
        
    }
    
    /*
     * Default value
     */
    private function getDefaultOptions() {
        
        return array(
            'type' => 'Dialogue',
            'start' => '0:00:00.00',
            'end' => '0:00:01.00',
            'content' => '',
            'last_modified' => new Datetime(),
            'style' => new Style(array()),
            'is_modified' => 0
        );
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
   
    /**
     * Set start
     *
     * @param string $start
     * @return Srt
     */
    public function setStart($start)
    {
        $this->start = $start;

        return $this;
    }

    /**
     * Get start
     *
     * @return string 
     */
    public function getStart()
    {
        return $this->start;
    }

    /**
     * Set end
     *
     * @param string $end
     * @return Srt
     */
    public function setEnd($end)
    {
        $this->end = $end;

        return $this;
    }

    /**
     * Get end
     *
     * @return string 
     */
    public function getEnd()
    {
        return $this->end;
    }

    /**
     * Set content
     *
     * @param string $content
     * @return Srt
     */
    public function setContent($content)
    {
        $this->content = $content;

        return $this;
    }

    /**
     * Get content
     *
     * @return string 
     */
    public function getContent()
    {
        return $this->content;
    }

    /**
     * Set type
     *
     * @param string $type
     * @return Srt
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

    /**
     * Get type
     *
     * @return string 
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * Set ass
     *
     * @param \Sm\AssBundle\Entity\Ass $ass
     * @return Srt
     */
    public function setAss(\Sm\AssBundle\Entity\Ass $ass)
    {
        $this->ass = $ass;

        return $this;
    }

    /**
     * Get ass
     *
     * @return \Sm\AssBundle\Entity\Ass 
     */
    public function getAss()
    {
        return $this->ass;
    }

    /**
     * Set line
     *
     * @param integer $line
     * @return Srt
     */
    public function setLine($line)
    {
        $this->line = $line;

        return $this;
    }

    /**
     * Get line
     *
     * @return integer 
     */
    public function getLine()
    {
        return $this->line;
    }

    /**
     * Set last_modified
     *
     * @param \DateTime $lastModified
     * @return Srt
     */
    public function setLastModified($lastModified)
    {
        $this->last_modified = $lastModified;

        return $this;
    }

    /**
     * Get last_modified
     *
     * @return \DateTime 
     */
    public function getLastModified()
    {
        return $this->last_modified;
    }

    /**
     * Set is_modified
     *
     * @param boolean $isModified
     * @return Srt
     */
    public function setIsModified($isModified)
    {
        $this->is_modified = $isModified;

        return $this;
    }

    /**
     * Get is_modified
     *
     * @return boolean 
     */
    public function getIsModified()
    {
        return $this->is_modified;
    }

    /**
     * Set style
     *
     * @param \Sm\AssBundle\Entity\Style $style
     * @return Srt
     */
    public function setStyle(\Sm\AssBundle\Entity\Style $style = null)
    {
        $this->style = $style;

        return $this;
    }

    /**
     * Get style
     *
     * @return \Sm\AssBundle\Entity\Style 
     */
    public function getStyle()
    {
        return $this->style;
    }
}
